import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    name: 'home',
    component: () => import('@/views/home'),
    children: [
      {
        path: 'index',
        name: 'index',
        components: {
          content: () => import('@/views/Index'),
          nav: () => import('@/views/Index/Navbar')
        }
      },
      {
        path: 'testQues',
        name: 'testQues',
        components: {
          content: () => import('@/views/Ques/testQues'),
          nav: () => import('@/views/Ques/testQues/Navbar')
        }
      },
      {
        path: 'addQues',
        name: 'addQues',
        components: {
          content: () => import('@/views/Ques/addQues'),
          nav: () => import('@/views/Index/Navbar')
        }
      },
      {
        path: 'editQues',
        name: 'editQues',
        components: {
          content: () => import('@/views/Ques/editQues'),
          nav: () => import('@/views/Ques/editQues/Navbar')
        }
      },
      {
        path: 'testPaper',
        name: 'testPaper',
        components: {
          content: () => import('@/views/Paper/testPaper'),
          nav: () => import('@/views/Paper/testPaper/Navbar')
        }
      },
      {
        path: 'addPaper',
        name: 'addPaper',
        components: {
          content: () => import('@/views/Paper/addPaper'),
          nav: () => import('@/views/Paper/addPaper/Navbar')
        }
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/Login')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/Register')
  },
  {
    path: '/contesting/:id',
    name: 'contesting',
    component: () => import('@/views/Contest/contesting')
  },
  {
    path: '/showScore',
    name: 'showScore',
    component: () => import('@/views/Contest/showScore')
  },
  {
    path: '*',
    redirect: '/notfound'
  },
  {
    path: '/notfound',
    name: 'notfound',
    component: () => import('@/views/NotFound')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
